package com.itheima.search.controller;


import com.itheima.search.model.constant.MessageConstant;
import com.itheima.search.model.entity.PageResult;
import com.itheima.search.model.entity.QueryPageBean;
import com.itheima.search.model.entity.Result;
import com.itheima.search.model.pojo.CheckGroup;
import com.itheima.search.service.CheckgroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Lee
 * @created 2024/5/9
 * @describtion
 */
@RestController
@RequestMapping("/checkgroup")
@Api("检查组管理接口")
@Slf4j
public class CheckgroupController {
    @Autowired
    private CheckgroupService checkgroupService;

    /**
     * 新增检查组
     *
     * @param checkGroup
     * @return
     */
    @PostMapping("/add.do")
    @ApiOperation("新增检查组")
    public Result add(@RequestBody CheckGroup checkGroup) {
        log.info("新增检查组:{}", checkGroup);
        checkgroupService.save(checkGroup);
        return new Result(true, MessageConstant.ADD_CHECKGROUP_SUCCESS);
    }

    /**
     * 分页查询
     *
     * @param queryPageBean
     * @return
     */
    @PostMapping("/findPage.do")
    @ApiOperation("检查组分页查询-条件查询")
    public PageResult page(@RequestBody QueryPageBean queryPageBean) {
        log.info("检查组分页查询-条件查询:{}", queryPageBean);
        PageResult pageResult = checkgroupService.page(queryPageBean);
        return pageResult;
    }



}
